var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("GlobalParams"),
    a = e("AudioManager"),
    i = e("ModuleUI"),
    r = e("CommonHelper"),
    s = e("Game"),
    l = e("UIManager"),
    c = e("GetZsViewUI"),
    d = cc._decorator,
    h = d.ccclass,
    _ = d.property,
    u = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (t.shop_content_node = null), t;
        }
        return (
            __extends(t, e),
            (t.prototype.initView = function () {
                (this.uiManager = cc.find("UIManager").getComponent(l.default)),
                    this.node.getComponent(cc.ScrollView).scrollToLeft(0.1);
            }),
            (t.prototype.start = function () {
                for (var e = 0; e < this.shop_content_node.childrenCount; e++) {
                    var t = this.shop_content_node.children[e],
                        o = s.default.shop_coin_info[e];
                    (t.name = "coin_" + e),
                        (t.getChildByName("coin_node").children[0].getComponent(cc.Label).string = "" + o.coin);
                    var n = t.getChildByName("dis_count"),
                        a = t.getChildByName("buy_btn");
                    1 == o.discount
                        ? ((n.active = !1), (a.getChildByName("dis_count").active = !1))
                        : ((n.active = !0),
                          (n.children[0].getComponent(cc.Label).string = 10 * o.discount + "折"),
                          (a.getChildByName("dis_count").getComponent(cc.Label).string = "" + o.zs),
                          (a.getChildByName("dis_count").active = !0)),
                        (a.getChildByName("zs_node").children[1].getComponent(cc.Label).string =
                            "" + o.zs * o.discount),
                        a.on("click", this.buyCoinInfo, this);
                }
            }),
            (t.prototype.buyCoinInfo = function (e) {
                a.default.ButtonSound();
                var t = e.node.parent.name,
                    o = Number(r.default.getNameType(t, "coin_")),
                    i = s.default.shop_coin_info[o];
                n.GlobalParams.PlayerInfo.value.zs >= i.zs * i.discount
                    ? (this.uiManager.consumeCoinAndZs(1, i.zs * i.discount), this.uiManager.addCoinAni(i.coin, 0))
                    : this.uiManager.showPopup("GetZsViewUI", function (e) {
                          e.getComponent(c.default).showPopupInfoView(0);
                      });
            }),
            __decorate([_(cc.Node)], t.prototype, "shop_content_node", void 0),
            __decorate([h], t)
        );
    })(i.default);
o.default = u;
